package org.apache.doris.demo.spring.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.extension.toolkit.SqlHelper;
import com.baomidou.mybatisplus.extension.toolkit.SqlRunner;
import org.apache.doris.demo.spring.mapper.LabelTagBitmapMapper;
import org.apache.doris.demo.spring.mapper.UserIdBhMapper;
import org.apache.doris.demo.spring.model.LabelTagBitmap;
import org.apache.doris.demo.spring.model.UserIdBh;
import org.apache.doris.demo.spring.service.LabelTagBitmapService;
import org.apache.doris.demo.spring.service.UserIdBhService;
import org.springframework.stereotype.Service;

import java.sql.Timestamp;
import java.util.List;
import java.util.Map;

@Service
public class LabelTagBitmapServiceImpl extends ServiceImpl<LabelTagBitmapMapper, LabelTagBitmap> implements LabelTagBitmapService {
    @Override
    public boolean save(LabelTagBitmap entity) {
        Long useridl = Long.valueOf(entity.getUserid());
        Timestamp timestamp = Timestamp.valueOf(entity.getInsertTime());
        Map<String, Object> stringObjectMap = SqlRunner.db().selectOne("INSERT INTO `labels`.`label_tag_bitmap`  VALUES\n" +
                "({0}, {1}, {2},{3}, {4},to_bitmap({5}))",entity.getTagName(),entity.getTagValue(), useridl * 3L /10000000000l,entity.getSubject(),timestamp.toString(),useridl);
        return true;
    }

    @Override
    public List<LabelTagBitmap> selectByMap(Map<String, Object> columnMap) {
        return null;
    }
}
